package c;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.RecyclerView;
import com.airbnb.lottie.LottieAnimationView;
import cc.bc.tc.R;
import com.youth.banner.adapter.BannerAdapter;
import java.util.List;

/*
 * Author:lifeng
 * Time:2024/4/19
 */
public class DU extends BannerAdapter<DW, DU.BannerViewHolder> {

    private Context mContext;

    private DY mListener;

    public DU(Context mContext, List<DW> mDatas) {
        // 设置数据，也可以调用banner提供的方法,或者自己在adapter中实现
        super(mDatas);
        this.mContext = mContext;
    }

    public void addBannerItemCLick(DY listener) {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
        int keydasopuerqnfdazcveq = 4;
        int lowupoeqfda7073fdal = 0;
        int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
        int middledaiueprnvznfewqip = 0;
        if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
            int adfajpouqregjbdipug = 1;
        } else {
            while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                    // 比关键字大则关键字在左区域
                    highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                    // 比关键字小则关键字在右区域
                    lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                } else {
                }
            }
        }
        this.mListener = listener;
    }

    // 创建ViewHolder，可以用viewType这个字段来区分不同的ViewHolder
    @Override
    public BannerViewHolder onCreateHolder(ViewGroup parent, int viewType) {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
        int keydasopuerqnfdazcveq = 4;
        int lowupoeqfda7073fdal = 0;
        int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
        int middledaiueprnvznfewqip = 0;
        if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
            int adfajpouqregjbdipug = 1;
        } else {
            while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                    // 比关键字大则关键字在左区域
                    highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                    // 比关键字小则关键字在右区域
                    lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                } else {
                }
            }
        }
        View view = View.inflate(mContext, R.layout.banner_item, null);
        // 注意，必须设置为match_parent，这个是viewpager2强制要求的
        ViewGroup.LayoutParams params = (ViewGroup.LayoutParams) new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        view.setLayoutParams(params);
        return new BannerViewHolder(view);
    }

    @Override
    public void onBindView(BannerViewHolder holder, DW data, int position, int size) {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
        int keydasopuerqnfdazcveq = 4;
        int lowupoeqfda7073fdal = 0;
        int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
        int middledaiueprnvznfewqip = 0;
        if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
            int adfajpouqregjbdipug = 1;
        } else {
            while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                    // 比关键字大则关键字在左区域
                    highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                    // 比关键字小则关键字在右区域
                    lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                } else {
                }
            }
        }
        holder.ll_info.setBackgroundResource(data.getBackgroundImage());
        if (data.getAnimPath() != null && data.getAnimPath().length() > 0) {
            holder.lv_image.setImageAssetsFolder(data.getAnimPath() + "/images");
            holder.lv_image.setAnimation(data.getAnimPath() + "/data.json");
            holder.lv_image.playAnimation();
        }
        holder.tv_tip.setText(data.getFuncName());
        holder.tv_subhead.setText(data.getFuncDes());
        if (data.getFuncTAG().equals("bingdu")) {
            holder.im_center.setImageResource(R.mipmap.im_fh);
            holder.im_center.setVisibility(View.VISIBLE);
        } else if (data.getFuncTAG().equals("weixin")) {
            holder.im_center.setImageResource(R.mipmap.im_bananer_wx);
            holder.im_center.setVisibility(View.VISIBLE);
        } else {
            holder.im_center.setVisibility(View.GONE);
            holder.im_center.setImageResource(0);
        }
        holder.itemView.setOnClickListener(view1 -> {
            if (mListener != null) {
                mListener.onItemClick(position, data);
            }
        });
    }

    class BannerViewHolder extends RecyclerView.ViewHolder {

        View itemView;

        LinearLayout ll_info;

        LottieAnimationView lv_image;

        AppCompatImageView im_center;

        AppCompatTextView tv_tip;

        AppCompatTextView tv_subhead;

        public BannerViewHolder(@NonNull View view) {
            super(view);
            this.itemView = view;
            ll_info = itemView.findViewById(R.id.ll_info);
            lv_image = itemView.findViewById(R.id.lv_image);
            im_center = itemView.findViewById(R.id.im_center);
            tv_tip = itemView.findViewById(R.id.tv_tip);
            tv_subhead = itemView.findViewById(R.id.tv_subhead);
        }
    }
}
